package cn.tedu.test.rabbitmq.consumer;

import cn.tedu.test.rabbitmq.domain.User;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class DemoConsumer {
    @RabbitListener(queues = {"demo-queue"})
    public void receive01(User user){
        //底层channel.basicConsume(#{demo-queue},autoAck,user反序列化)
        //业务消费者 只需要关心拿到消息体之后 如何执行消费逻辑
        System.out.println("demo-queue消费者收到消息:"+user.getName());
    }
    @RabbitListener(queues = {"queue1"})
    public void receive02(String msg){
        //底层channel.basicConsume(#{demo-queue},autoAck,user反序列化)
        //业务消费者 只需要关心拿到消息体之后 如何执行消费逻辑
        System.out.println("queue1消费者收到消息:"+msg);
    }
    //在当前消费类中,底层绑定当前类的消费方法 到一个消费逻辑,
    /*public void receive01(String msg){
        System.out.println("消费者收到消息:"+msg);
    }
    public void receive02(String msg){
        System.out.println("消费者收到消息:"+msg);
    }
    public void receive03(User msg){
        System.out.println("消费者收到消息:"+msg);
    }*/
}
